{% assign data = section.settings %}
{% assign blockId = block_id | default: section.block_id %}

<div class="block_image_text_list">
  <div class="container_wrapper">
    {% include 'title', title: data.block_title, detail: data.block_detail %}
    <div class="swiper relative overflow-hidden" id="swiper-{{blockId}}">
      <ul class="swiper-wrapper md:grid md:gap-5 text-center" style="--pc-number: {{data.pc_number}};">
        {% for block in section.blocks %}
          <li class="swiper-slide public_radius overflow-hidden relative grid">
            <div class="img_box relative">
              {% include 'lazy_img', src: block.image.src, alt: block.image.alt, class: 'w-full h-full object-cover' %}
			  <div class="mask absolute w-full h-full left-0 top-0" style="--mask-color: {{block.mask_color}};"></div>
            </div>
            <div class="text_box box-border md:p-[30px] p-[15px]" style="--text-color: {{block.text_color}};">
              <div class="text_content md:mb-0 mb-10">
                {% if block.subtitle != '' %}
                    <div class="text_subtitle mb-3 uppercase">{{block.subtitle}}</div>
                {% endif %}
                {% if block.title != '' %}
                  <div class="text_title public_title uppercase mb-3">{{ block.title }}</div>
                {% endif %}
                {% if block.detail != '' %}
                  <div class="text_detail">{{ block.detail }}</div>
                {% endif %}
                {% if block.btn_text != '' %}
                  <div class="btn_wrap mt-4" style="--btn-bg: {{block.btn_bg}};--btn-color: {{block.btn_color}};">
                    <a class="public_btn" href="{{block.link | setUrlDataFrom:data_from}}">{{ block.btn_text }}</a>
                  </div>
                {% endif %}
              </div>
            </div>
            {% if block.btn_text == '' %}
                <a class="absolute w-full h-full top-0 left-0 z-10" href="{{block.link | setUrlDataFrom:data_from}}"></a>
            {% endif %}
          </li>
        {% endfor %}
      </ul>
      <div class="swiper-pagination" id="swiper-pagination-{{blockId}}"></div>
    </div>
  </div>
</div>

<script>
$(function() {
    if($(window).width() < 768) {
        let swiper = new Swiper('#swiper-{{blockId}}', {
            pagination: {
                el: '#swiper-pagination-{{blockId}}',
                clickable :true
            }
        })
    }
})
</script>

{% schema %}
{
	"class": "block_image_text_list",
	"is_global": false,
	"icon": "icon-tuwenliebiao",
	"name": {
		"zh_CN": "图文列表",
		"en_US": "Image-text list"
	},
	"max_blocks": "12",
	"blocks": [
		{
			"name": {
				"zh_CN": "图文列表",
				"en_US": "Image-text list"
			},
			"type": "item",
			"settings": [
				{
					"type": "card_image",
					"label": {
						"zh_CN": "图片",
						"en_US": "Image"
					},
					"default": {
						"src": "",
						"alt": ""
					},
					"info": {
						"zh_CN": "建议宽度1000px以上，高度自适应",
						"en_US": "Recommended width more than 1000px, height adaptive"
					},
					"id": "image"
				},
				{
					"type": "card_input",
					"label": {
						"zh_CN": "副标题",
						"en_US": "Subtitle"
					},
					"id": "subtitle",
					"default": ""
				},
				{
					"type": "card_input",
					"label": {
						"zh_CN": "标题",
						"en_US": "Title"
					},
					"id": "title",
					"default": ""
				},
				{
					"type": "card_text_editor",
					"label": {
						"zh_CN": "简短描述",
						"en_US": "Short description"
					},
					"id": "detail",
					"default": ""
				},
				{
					"type": "card_input",
					"label": {
						"zh_CN": "按钮文字",
						"en_US": "Button text"
					},
					"id": "btn_text",
					"default": ""
				},
				{
					"type": "card_page_link",
					"label": {
						"zh_CN": "跳转链接",
						"en_US": "Jump links"
					},
					"default": {
						"type": "",
						"title": "",
						"url": ""
					},
					"id": "link"
				},
				{
					"type": "card_header",
					"label": {
						"zh_CN": "颜色设置",
						"en_US": "Color Settings"
					}
				},
				{
					"type": "card_color",
					"id": "text_color",
					"label": {
						"zh_CN": "文字颜色",
						"en_US": "Text color"
					},
					"default": "#141414"
				},
				{
					"type": "card_color",
					"id": "btn_color",
					"label": {
						"zh_CN": "按钮文字颜色",
						"en_US": "Button text color"
					},
					"default": "#ffffff"
				},
				{
					"type": "card_color",
					"id": "btn_bg",
					"label": {
						"zh_CN": "按钮背景颜色",
						"en_US": "Button background color"
					},
					"show-alpha": "false",
					"color-format": "rgb",
					"default": "rgba(223,86,65,1)"
				},
				{
					"type": "card_color",
					"label": {
						"zh_CN": "蒙层颜色",
						"en_US": "Mask color"
					},
					"show-alpha": "false",
					"color-format": "rgb",
					"default": "rgba(0,0,0,0)",
					"id": "mask_color"
				}
			]
		}
	],
	"settings": [
		{
			"type": "card_header",
			"label": {
				"zh_CN": "设置",
				"en_US": "Settings"
			}
		},
		{
			"type": "card_input",
			"label": {
				"zh_CN": "标题",
				"en_US": "Title"
			},
			"default": "",
			"id": "block_title"
		},
		{
			"type": "card_text_editor",
			"label": {
				"zh_CN": "描述",
				"en_US": "Description"
			},
			"id": "block_detail",
			"default": ""
		},
		{
			"type": "card_slider",
			"label": {
				"zh_CN": "PC每排数量",
				"en_US": "PC number per row"
			},
			"id": "pc_number",
			"max": "5",
			"min": "3",
			"default": "4"
		}
	],
	"default": {
		"settings": {
			"block_title": "",
			"block_detail": "",
			"pc_number": 3
		},
		"blocks": [
			{
				"image": {
					"src": "",
					"alt": ""
				},
				"subtitle": "",
				"title": "Add a title or tagline",
				"detail": "Share blog posts, products, or promotions with your customers. Use this text to describe products, share details on availability and style, or as a space to display recent reviews or FAQs.",
				"btn_text": "Optional button",
				"link": {
					"type": "",
					"title": "",
					"url": ""
				},
				"text_color": "#141414",
				"btn_color": "#ffffff",
				"btn_bg": "rgba(223,86,65,1)",
				"mask_color": "rgba(0,0,0,0)",
				"block_type": "item"
			},
			{
				"image": {
					"src": "",
					"alt": ""
				},
				"subtitle": "",
				"title": "Add a title or tagline",
				"detail": "Share blog posts, products, or promotions with your customers. Use this text to describe products, share details on availability and style, or as a space to display recent reviews or FAQs.",
				"btn_text": "Optional button",
				"link": {
					"type": "",
					"title": "",
					"url": ""
				},
				"text_color": "#141414",
				"btn_color": "#ffffff",
				"btn_bg": "rgba(223,86,65,1)",
				"mask_color": "rgba(0,0,0,0)",
				"block_type": "item"
			},
			{
				"image": {
					"src": "",
					"alt": ""
				},
				"subtitle": "",
				"title": "Add a title or tagline",
				"detail": "Share blog posts, products, or promotions with your customers. Use this text to describe products, share details on availability and style, or as a space to display recent reviews or FAQs.",
				"btn_text": "Optional button",
				"link": {
					"type": "",
					"title": "",
					"url": ""
				},
				"text_color": "#141414",
				"btn_color": "#ffffff",
				"btn_bg": "rgba(223,86,65,1)",
				"mask_color": "rgba(0,0,0,0)",
				"block_type": "item"
			}
		]
	}
}
{% endschema %}
